@import '../style/var';

.van-switch {
  position: relative;
  display: inline-block;
  box-sizing: content-box;
  min-width: @switch-width;
  height: @switch-height;
  font-size: @switch-size;
  background-color: @switch-background-color;
  border: calc(var(--border-width-base) * 2) solid @gray-2;
  border-radius: @switch-node-size;
  cursor: pointer;
  transition: background-color @switch-transition-duration;

  &__node {
    position: absolute;
    top: 0;
    left: 0;
    width: @switch-node-size;
    height: @switch-node-size;
    background-color: @switch-node-background-color;
    border-radius: 100%;
    box-shadow: @switch-node-box-shadow;
    transition: all @switch-transition-duration
      cubic-bezier(0.3, 1.05, 0.4, 1.05);
  }

  &__loading {
    top: 25%;
    left: 25%;
    width: 50%;
    height: 50%;
    line-height: 1;
  }

  &--on {
    background-color: @switch-on-background-color;
    border: calc(var(--border-width-base) * 2) solid @switch-on-background-color;
    .van-switch__node {
      left: 100%;
      transform: translateX(-100%);
    }

    .van-switch__loading {
      color: @switch-on-background-color;
    }
  }

  &--disabled {
    cursor: not-allowed;
    opacity: @switch-disabled-opacity;
  }

  &--loading {
    cursor: default;
  }

  &__text-wrap {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;

    padding: 0 2px;

    &--active {
      margin-right: @switch-node-size;
      color: @switch-text-active-color;
    }

    &--inactive {
      margin-left: @switch-node-size;
      color: @switch-text-inactive-color;
    }
  }

  &__text {
    font-size: @switch-text-size;
  }
}
